package dp.test121;

/**
 * @author code_yc
 * @version 1.0
 * @date 2020/7/23 9:07
 */
public class Solution1 {

    public int maxProfit(int[] prices) {
        int ans = 0;
        int temp = 0;
        int cur = 0;
        for (int i = 0; i < prices.length - 1; i++) {
            temp = prices[i + 1] - prices[i];
            cur = cur > 0 ? cur + temp : temp;
            ans = Math.max(cur, ans);
        }
        return ans;
    }
}
